const Mock = require('mockjs')
const count=100;
const PurchaseList=[];

for(let i=0;i<count;i++){
    PurchaseList.push(Mock.mock({
      id: '@increment',
      ordernumber:'@integer(209011234,579011234)',
      paynumber:'@integer(209011234,579011234)',
      carname:'@first',
      priceandtax:'@integer(20011234,57011234)',
      purchasetype:'@first',
      supplier:'@first',
      guider:'@first',
      paystage:'@integer(0,4)',
      paystate:'@integer(0,5)',
      storestate:'@integer(0,1)',
      createtime:'@datetime',
    }))
  
  }

  const CarStoreList=[]
  for(let i=0;i<count;i++){
    CarStoreList.push(Mock.mock({
      id: '@increment',
      ordernumber:'@integer(209011234,579011234)',
      paynumber:'@integer(209011234,579011234)',
      carname:'@first',
      storename:'@integer(11234,8234)',
      storeplace:'@first',
      entrytime:'@datetime',
      paytime:'@datetime',
      payday:'@integer(1,100)',
      
      lendstage:'@integer(0,1)',
      refitstate:'@integer(0,1)',
      storestate:'@integer(0,1)',
      createtime:'@datetime',
    }))
  
  }

  const DistributeList=[]
  for(let i=0;i<count;i++){
    DistributeList.push(Mock.mock({
      id: '@increment',
      ordernumber:'@integer(209011234,579011234)',
      purchasenumber:'@integer(209011234,579011234)',
      carname:'@first',
      customername:'@first',
      guider:'@first',
      storename:'@integer(11234,8234)',
      depart:'@first',
      state:'@integer(0,4)',
      createtime:'@datetime',
    }))
  
  }

  const DistributeAfterList=[]
  for(let i=0;i<count;i++){
    DistributeAfterList.push(Mock.mock({
      id: '@increment',
      ordernumber:'@integer(209011234,579011234)',
      vincode:'@integer(209011234,579011234)',
      carname:'@first',
      customername:'@first',
      guider:'@first',
      storename:'@integer(11234,8234)',
      storeplace:'@integer(11234,8234)',
      state:'@integer(0,4)',
      licensestate:'@integer(0,1)',
      extrastate:'@integer(0,1)',
      createtime:'@datetime',
    }))
  
  }

module.exports=[
    //salesliplist
    {
        url: '/api/cars/purchaselist',
        type: 'get',
        response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query
    
          let mockList = PurchaseList.filter(item => {
            return true
          })
    
          if (sort === '-id') {
            mockList = mockList.reverse()
          }
    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },

    {
      url: '/api/cars/storelist',
      type: 'get',
      response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query
    
          let mockList = CarStoreList.filter(item => {
            return true
          })
    
          if (sort === '-id') {
            mockList = mockList.reverse()
          }
    
          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
    
          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
    },
    {
      url: '/api/cars/distributelist',
      type: 'get',
      response: config => {
          const { importance, type, title, page = 1, limit = 20, sort } = config.query

          let mockList = DistributeList.filter(item => {
            return true
          })

          if (sort === '-id') {
            mockList = mockList.reverse()
          }

          const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))

          return {
            code: '10000',
            data: {
              total: mockList.length,
              items: pageList
            }
          }
        }
      },
      {
        url: '/api/cars/distributeafterlist',
        type: 'get',
        response: config => {
            const { importance, type, title, page = 1, limit = 20, sort } = config.query
  
            let mockList = DistributeAfterList.filter(item => {
              return true
            })
  
            if (sort === '-id') {
              mockList = mockList.reverse()
            }
  
            const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
  
            return {
              code: '10000',
              data: {
                total: mockList.length,
                items: pageList
              }
            }
          }
        },
]